package com.dodoke.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dodoke.dto.RetailAreaDTO;
import com.dodoke.entity.RetailArea;
import com.dodoke.mapper.RetailAreaMapper;
import com.dodoke.service.IRetailAreaService;
import com.dodoke.vo.RetailAreaListVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 经销区域业务层实现
 */
@Service
public class RetailAreaServiceImpl extends ServiceImpl<RetailAreaMapper, RetailArea> implements IRetailAreaService {

    @Resource
    private RetailAreaMapper retailAreaMapper;

    /**
     * 经销区域分页列表
     *
     * @param currentPage   当前页码
     * @param pageSize      每页显示条数
     * @param retailAreaDTO 模糊查询条件
     * @return
     */
    @Override
    public Page<RetailAreaListVO> getListByPage(Integer currentPage, Integer pageSize, RetailAreaDTO retailAreaDTO) {
        Page<RetailAreaListVO> page = new Page<>(currentPage, pageSize);
        page = retailAreaMapper.selectByList(page, retailAreaDTO);
        return page;
    }

    /**
     * 新增经销区域
     *
     * @param retailArea
     * @return
     */
    @Override
    public int saveRetailArea(RetailArea retailArea) {
        retailArea.setDelFlag("0");
        return retailAreaMapper.insertRetailArea(retailArea);
    }
}
